<!DOCTYPE html>
<html lang="zh-cn">
	<head>
	    <meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	    <meta name="viewport" content="width=device-width, initial-scale=1">
	    <#include "/common/meta.ftl"/>
	    <#include "/common/form.ftl"/>
	    <link rel="stylesheet" href="${_b}/static/zTree_v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
	    <script type="text/javascript" src="${_b}/static/zTree_v3/js/jquery.ztree.all.js"></script>
		<script>
			$(function(){
				$("#btnRight").click(function(){
					parent.location.href = "grantApp?roleId=${roleId}";
				});
				$("#btnSearch").click(function(){
					if($('#query').val()=='请输入关键字'){
						$('#query').val('');
					}
					$("#page").val(1);
					$('#form')[0].submit();
				});	
				<#if (flag!'')!=''>
				var msg = new top.$.zui.Messager('提示消息：${flag!''}', {
		                	type : 'success',
		                	fade : true,
		                	icon : 'ok-sign',
		                	time : 3000,
		                	scale : true
		    	});
				msg.show();
				</#if>
			});
			function update(userId,type){
				var operation = 1;
				if(type){
					operation = 1;
				}else{
					operation = 0;
				}
				$.getJSON("roleUserJSave", { type:operation,roleId: '${roleId}', userId: userId }, function(json){
					if(json.success){
						var msg = new top.$.zui.Messager('提示消息：'+json.msg, {
		                	type : 'success',
		                	fade : true,
		                	icon : 'ok-sign',
		                	time : 3000,
		                	scale : true
		                });
		                msg.show();
					}
				});
			}
			function grantRolesOfOneUser(url){
				top.openWindow('单用户授权角色窗口',url,function(){
					top.$("#mainIframe").attr("src","${_b}/admin/grantUser2?roleId=${roleId}");
				},{
					width:700
				});
			}
		</script>
	</head>
	<body style="padding:5px;">
			<form id="form" class="form-horizontal" role="form" method='post' action="./grantUser?roleId=${roleId}">
		          		<table style="width:100%;margin-bottom:5px;">
		          			<tr>
		          				<td>
		          					<strong>角色【${roleName!''}】</strong>
		          				</td>
		          				<td width="400px" align=right>
		          					<div class="input-group" style="width:190px;">
		          						<span class="input-group-addon">登录名</span>
		          						<input type="text" id="userLoginName" name="userLoginName" value="${userLoginName!''}" class="form-control" style="width:120px;"/>
		          						<span class="input-group-addon fix-border">用户名</span>
		          						<input type="text" id="userName" name="userName" value="${userName!''}" class="form-control" style="width:120px;"/>
		          						<span class="input-group-btn">
		          							<button class="btn btn-primary" id="btnSearch" name="btnSearch" type="button"><i class="icon icon-search"></i> 查询</button>
					             			<button class="btn btn-warning" id="btnRight" name="btnRight" type="button"><i class="icon icon-magic"></i> 应用</button>
											<button class="btn" type="button" onclick="parent.location.href='./role'"><i class="icon icon-reply"></i> 返回</button>	
		          						</span>
		          					</div>
		          				</td>
							</tr>
						</table>	             	
				<table class="table table-hover table-bordered table-condensed" style="margin:0px;">
				  	<thead>
				    	<tr>
					      	<th style="width:50px;text-align:center;">选择</th>
					      	<th style="width:50px;text-align:center;">序号</th>
					      	<th style="text-align:center;width:120px;">登录名</th>
					      	<th style="text-align:center;width:120px;">用户名</th>
					      	<th style="text-align:center;">所属部门</th>
					      	<th style="text-align:center;width:80px;">排序</th>
					      	<th style="text-align:center;width:80px;">状态</th>
				    	</tr>
				  	</thead>
					<tbody>
				<#list data.records as x>
	  			<tr>
	  				<td style="text-align:center">
	  					<input type="checkbox" class="CK" <#if (x.roleSelected!'')!=''>checked</#if> onclick="update('${x.userID!''}',this.checked)" />
	  				</td>
	  				<td style="text-align:center">${x_index+1}</td>
			      	<td style="text-align:center">
			      	<a href="javascript:void(0);" onclick="grantRolesOfOneUser('./grantRoleByUser?userId=${x.userID}');"><#---->
			      	${x.userLoginName?default('')}
			      	</a>
			      	</td>
			      	<td style="text-align:center">${x.userName?default('')}</td>
			      	<td style="text-align:left">${x.organName?default('')}</td>
			      	<td style="text-align:center">${x.userOrder?default('')}</td>
			      	<td style="text-align:center">
				      	<#if x.userStatus?exists&&x.userStatus==1>
				      	<span style=color:green><b>正常</b></span>
				      	<#elseif x.userStatus?exists&&x.userStatus==11>
				      	<span style=color:orange><b>未激活</b></span>
				      	<#else>
				      	<span style=color:red><b>已停用</b></span>
				      	</#if>
			      	</td>
			    </tr>
			    </#list>
					</tbody>
				</table>
			<#include "/common/page_v1.ftl"/>
	    	</form>
	</body>
</html>
